package com.aviator;

import com.googlecode.aviator.runtime.function.AbstractVariadicFunction;
import com.googlecode.aviator.runtime.function.FunctionUtils;
import com.googlecode.aviator.runtime.type.AviatorBigInt;
import com.googlecode.aviator.runtime.type.AviatorObject;
import com.googlecode.aviator.runtime.type.AviatorString;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Author: Jiangxx
 * @Date: 2021/08/06/17:49
 * @Description:
 */
public class MyMethods extends AbstractVariadicFunction {
    @Override
    public AviatorObject variadicCall(Map<String, Object> map, AviatorObject... aviatorObjects) {
        if(aviatorObjects == null){
            return new AviatorString(null);
        }
        List<Integer> integer = new ArrayList<>();
        for (AviatorObject abs : aviatorObjects){
            if (FunctionUtils.getNumberValue(abs, map).intValue() > 10) {
                integer.add(FunctionUtils.getNumberValue(abs, map).intValue());
            }else{
                break;
            }
        }
        return (AviatorObject) integer;
    }

    @Override
    public String getName() {
        return "getNums";
    }
}
